$("document").ready(function() {
$("input[type=text], input[type=password]").attr('autocomplete', 'off');
    
    $("form#registerForm button[type=submit]").click(function(event) {
        
        event.preventDefault();
        $("#loading").fadeToggle();
        $.ajax({
            type: 'POST',
            url: "{{ path('OweimMainBundle_register') }}",
            data: $("form").serialize(),
            cache: false,
            success: function(msg) {
                if(msg != 'OK') {
                    
                            
                    $("div#registerFormErrorBlock").html(msg);

                    if($("div#registerFormErrorBlock").is(":visible")) {
                        $("div#registerFormErrorBlock").toggle();
                    }
                    $("div#registerFormErrorBlock").fadeToggle();
                    $("#loading").fadeToggle();
                   
                } else {
                    window.location = "{{ path('OweimMainBundle_homepage') }}";
                }
            }
        });
        return false;
    });
});